<template>
    <div>
        <a-form-model layout="inline">
            <a-form-model-item>
                <a-input placeholder="Username">
                    <a-icon slot="prefix" type="user" style="color:rgba(0,0,0,.25)"/>
                </a-input>
            </a-form-model-item>
            <a-form-model-item>
                <a-input type="password" placeholder="Password">
                    <a-icon slot="prefix" type="lock" style="color:rgba(0,0,0,.25)"/>
                </a-input>
            </a-form-model-item>
            <a-form-model-item>
                <a-button
                        type="primary"
                        html-type="submit"
                >
                    Log in
                </a-button>
            </a-form-model-item>
        </a-form-model>
        {{token}}
        {{information}}
        <a-button @click="login">登录</a-button>
        <a-button @click="logout">退出</a-button>
        <a-button @click="info">信息</a-button>
    </div>
</template>

<script>
    import {postActionData} from "../api/master";

    export default {
        name: "Welcome",
        data() {
            return {
                information: {},
                token: null,
            }
        },
        methods: {
            info() {
                this.information.username = this.$store.getters.username;
                this.information.password = this.$store.getters.password;
                this.token = this.$store.getters.token;
            },
            login() {
                this.$store.dispatch('LOGIN', {username: "admin", password: "123456"}).then(() => {
                    this.$store.dispatch("LOGIN_INFO").catch(() => {
                        this.$message.warning("无法获取抓取用户信息！")
                    });
                }).catch(() => {
                    console.log("登录出现异常");
                });
            },
            logout() {
                this.$store.dispatch("LOGOUT").then(() => {

                });
            }
        }
    }
</script>

<style scoped>

</style>